﻿CREATE PROCEDURE [dbo].[yaf_nntpforum_update](
                @NntpForumID   INT,
                @LastMessageNo INT,
                @UserID        INT)
AS
    BEGIN
        DECLARE  @ForumID INT
        SELECT @ForumID = ForumID
        FROM   yaf_NntpForum
        WHERE  NntpForumID = @NntpForumID
        UPDATE yaf_NntpForum
        SET    LastMessageNo = @LastMessageNo,
               LastUpdate = Getdate()
        WHERE  NntpForumID = @NntpForumID
        UPDATE yaf_Topic
        SET    NumPosts = (SELECT COUNT(1)
                           FROM   yaf_message x
                           WHERE  x.TopicID = yaf_Topic.TopicID
                           AND (x.Flags & 24) = 16)
        WHERE  ForumID = @ForumID
        --exec yaf_user_upgrade @UserID
        EXEC yaf_forum_updatestats
             @ForumID
    -- exec yaf_topic_updatelastpost @ForumID,null
    END


